//
//  MapToolViewController.m
//  XhlTrip
//
//  Created by dlios on 15/9/28.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "MapToolViewController.h"
#import "MapButton.h"
#import "WeatherView.h"
#import "TranslationViewController.h"
#import "AccountViewController.h"
#import "MapViewController.h"
#import "ExchangeViewController.h"
@interface MapToolViewController ()<WeatherViewDelegate>
@property (nonatomic,retain)NSArray *imageArr;
@property (nonatomic,retain)NSArray *titleArr;
@property (nonatomic,retain)WeatherView *weatherView;
@end

@implementation MapToolViewController

- (void)viewDidLoad {

    
    [super viewDidLoad];
 

    UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    imageV.image = [UIImage imageNamed:@"go4.jpg"];
    [self.view  addSubview:imageV];
    [self addView];
}

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.imageArr = [NSArray arrayWithObjects:[UIImage imageNamed:@"yi.png"],[UIImage imageNamed:@"ka.png"],[UIImage imageNamed:@"ditu.png"],[UIImage imageNamed:@"qian.png"], nil];
        self.titleArr = [NSArray arrayWithObjects:@"语音翻译",@"旅行记账",@"旅行地图",@"实时汇率", nil];

    }
    return self;
}
- (void)addView
{
    
    
   self.weatherView = [[WeatherView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 306)];
    self.weatherView.delegate = self;
    self.weatherView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.2];
    
    [self.view addSubview:_weatherView];
    
    
    
    
    
    
    
    
    
    
    
    for (int i  = 0; i < 4; i ++) {
        
        
        MapButton *button = [MapButton buttonWithType:UIButtonTypeSystem];
        button.backgroundColor = [[UIColor cyanColor]colorWithAlphaComponent:0.1];
        button.imageV.image = [self.imageArr objectAtIndex:i];
        button.lable.text = [self.titleArr objectAtIndex:i];
        button.tag = i + 1;
        [button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(i % 2 * 185 + 4 , i / 2 * 154 + 309, 182, 151);
        [self.view addSubview:button];
        
    }
    
    
}
- (void)click:(UIButton *)button
{
    if (button.tag == 1) {
        TranslationViewController *translation = [[TranslationViewController alloc]init];
        translation.hidesBottomBarWhenPushed = YES;
        [self presentViewController:translation animated:YES completion:nil];
    }else if(button.tag == 2){
        AccountViewController *account = [[AccountViewController alloc]init];
        account.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:account animated:YES];
        
    }else if(button.tag == 3){
        MapViewController *map = [[ MapViewController alloc]init];
        [self.navigationController pushViewController:map animated:YES];
    }else{
        ExchangeViewController *change = [[ExchangeViewController alloc]init];
        
        [self.navigationController pushViewController:change animated:YES];
        
    }
}
- (void)gotoChooseViewController
{
    NSLog(@"1");
}

@end
